<template>
  <div class="flex1">
    <ksd-banner-vip></ksd-banner-vip>
    <ksd-channel-pay ref="channelPayRef" mode="channel"></ksd-channel-pay>
    <ksd-common-banner :channel-id="channelId"></ksd-common-banner>
    <div class="module owl-dynamic alert-primary">
      <ksd-scroll-list></ksd-scroll-list>
      <ksd-state-count :channel-id="channelId"></ksd-state-count>
    </div>
    <ksd-scroll-message></ksd-scroll-message>
    <div class="gui-padding mainbg7 c333 flex justify-between align-center fz12">
      <div class="flex1 tiplink">
        {{channelObj.description}}
      </div>
      <div class="btn-hidden" v-if="userStore.viptype == 1">
        <button v-if="channelObj.buyFlag==0" @click="handleChannelOpenBuyDialog()" class="gda-btn gda-btn-primary gda-btn-sm ml20" style="padding:4px 18px;"><i class="iconfont icon-fabu fz16 pr tp1 mr10"></i>订阅栏目</button>
        <span v-if="channelObj.buyFlag==1" class="gda-btn gda-btn-success gda-btn-sm ml20" style="padding:4px 18px;"><i class="iconfont icon-icon_right fz16 pr tp1 mr10"></i>已订阅</span>
      </div>
      <div v-else>
        <span v-if="userStore.isLogin" class="gda-btn gda-btn-success gda-btn-sm ml20" style="padding:4px 18px;"><i class="iconfont icon-icon_right fz16 pr tp1 mr10"></i>已订阅</span>
      </div>
    </div>
    <div class="ssd-contentbox">
      <ksd-common-push :channel-id="channelId"></ksd-common-push>
      <ksd-common-content :channel-id="channelId" :sorted="2"></ksd-common-content>
    </div>
  </div>
</template>
<script setup>
const channelObj = ref("")
const channelId = ref(1)
const userStore = useStore.userState()
const channelPayRef = ref({})
const handleChannelDetail = async ()=> {
  const resp = await useGetChannelDetail(channelId.value)
  channelObj.value = resp.data
}

const handleChannelOpenBuyDialog = async () => {
  await useLoginDialog()
  channelPayRef.value.handleOpen(channelId.value, channelObj.value.price,channelObj.value.title)
}

definePageMeta({
  layout: "nindex"
})

onMounted(() => {
  handleChannelDetail()
})

</script>
